package com.lw.yygh.hosp.controller;

import com.lw.yygh.hosp.service.HospService;
import com.lw.yygh.model.hosp.Hospital;
import com.lw.yygh.result.Result;
import com.lw.yygh.vo.hosp.HospitalQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;

@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {
    @Autowired
    private HospService hospService;
    //医院列表(条件分页查询)
    @GetMapping("/list/{page}/{limit}")
    public Result listHosp(@PathVariable("page") String page,
                           @PathVariable("limit") String limit,
                           HospitalQueryVo hospitalQueryVo) throws UnsupportedEncodingException {
        Page<Hospital> hospitalPage=hospService.findHospPage(Integer.parseInt(page),Integer.parseInt(limit),hospitalQueryVo);
        return Result.ok( hospitalPage );
    }
    //更新医院上线状态
    @GetMapping("/updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable String id,@PathVariable Integer status){
        hospService.updateHospStatus(id,status);
        return Result.ok();
    }
    //医院详情
    @GetMapping("/showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id){
        Hospital hospital=hospService.findHospById(id);
        return Result.ok( hospital );
    }
}
